<template>
  <div class="content-box">
    <!--form表单-->
    <el-form v-model="form">
      <!--内容-->
      <el-form-item label="公司名称">
        <el-input v-model="form.title" placeholder="输入公司名称"></el-input>
      </el-form-item>
      <el-form-item label="公司地址">
        <el-input
          v-model="form.address"
          placeholder="输入公司详细地址"
        ></el-input>
      </el-form-item>
      <el-form-item label="联系电话">
        <el-input v-model="form.tel" placeholder="输入公司联系电话"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { getCompany, setCompany } from "@/api/company";
import { ElMessage } from "element-plus";
const form = ref({
  title: "",
  address: "",
  tel: "",
});
onMounted(() => {
  getCompany().then((res: any) => {
    form.value = {
      title: res.data.title,
      address: res.data.address,
      tel: res.data.tel,
    };
  });
});

const submit = () => {
  setCompany(form.value).then((res: any) => {
    if (res.code == 1) {
      ElMessage.success("保存成功");
    } else {
      ElMessage.error(res.msg);
    }
  });
};
</script>

<style lang="scss" scoped>
.content-box {
  padding-bottom: 50px;
}

.mb50 {
  margin-bottom: 50px;
}
</style>
